<?php

namespace app\admin\model;

use think\Model;

class ProductBrand extends Model
{
    // 定义字段类型
    protected $type = [
        'id' => 'int',  // 将 id 字段强制转换为 int 类型
    ];

    public function getCreatorName()
    {
        return $this->getOperator()->bind(['create_name' => 'nickname']);
    }

    public function getUpdateName()
    {
        return $this->getUpdater()->bind(['update_name' => 'nickname']);
    }

    public function getOperator()
    {
        return $this->hasOne(Operator::class, 'id', 'creator');
    }

    public function getUpdater()
    {
        return $this->hasOne(Operator::class, 'id', 'updater');
    }

    public function getValueAttr($value, $data)
    {
        return $value . '';
    }
}
